package com.example.dubbo.business.controller;

import com.example.dubbo.api.dto.BusinessDTO;
import com.example.dubbo.api.dto.CommodityDTO;
import com.example.dubbo.api.response.ObjectResponse;
import com.example.dubbo.business.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @application:
 * @author: LiYuhang
 * @Date: 2021/9/20 22:44
 * @version: 0.1
 * @Description :
 */
@RestController
public class TestContrroller {
    @Autowired
    private BusinessService businessService;


    @RequestMapping(value = {"","index"})
    public void test() {
        BusinessDTO businessDTO=new BusinessDTO();
        businessDTO.setCommodityCode("C00321")
                .setCount(2)
                .setUserId("U100001")
                .setName("测试商品")
                .setAmount(BigDecimal.valueOf(20));
        ObjectResponse purchase = businessService.handleBusiness(businessDTO);
        System.out.println(purchase);
    }


    @RequestMapping(value = {"test"})
    public void test2() {
        BusinessDTO businessDTO=new BusinessDTO();
        businessDTO.setCommodityCode("C00321")
                .setCount(2)
                .setUserId("U100001")
                .setName("测试商品")
                .setAmount(BigDecimal.valueOf(20));
        ObjectResponse purchase = businessService.handleBusiness2(businessDTO);
        System.out.println(purchase);
    }


}
